<?php
   class Tours extends MY_Controller{
	   public function __construct(){
		   parent::__construct();
		   $this->load->model("model_tour");
		    $this->load->model("model_index");
	   }
	   public function index(){	// ha noi
		   $segment = $this->uri->segment(1);
		   //echo $segment;die();
		   $id = array_pop(explode('-',$segment));
		   $data['categories'] = $this->model_tour->get_categories($id);
		   $data['tourname']   = $this->model_index->getcate($id);
		   $data['introduc']    = $this->model_index->intro();
		   $data['config']  = $this->config();
		   if($id == 52){
			   $name = "Hanoi";
			   $catego = "Hanoi Tours";
			   $title = "Hanoi Travel";
		   }elseif($id == 88){
			   $name = "Halong";
			   $catego = "Halong Tours";
			   $title = "Halong Travel";
		   }else{
			   $name = "Vienam package";
			   $catego = "Vienam package";
			   $title = "Vietnam Package Tours";
		   }
		   $data['listtours'] = $this->model_tour->listtour($id);
		   $data['regions'] = $this->model_tour->regions($id);
		   $data['segment'] = $segment;
		   //$this->debug($data['destinations']);
		   $data['title']   = $title;
		   $data['name']    = $name; 
		   $data['catego']  = $catego;
		   $data['cateid']  = $id;
		   //$this->debug($data['categories']);
		   $this->load->view("tours/layout",$data);
	   }
	   public function cruise(){
		   $segment = $this->uri->segment(1);
		   $id = array_pop(explode('-',$segment));
		   $data['categories'] = $this->model_tour->get_categories($id);
		   $data['tourname']   = $this->model_index->getcate($id);
		   $data['config']  = $this->config();
		   if($id == 52){
			   $name = "Hanoi";
			   $catego = "Hanoi Tours";
			   $title = "Hanoi Travel";
		   }elseif($id == 88){
			   $name = "Halong";
			   $catego = "Halong Tours";
			   $title = "Halong Travel";
		   }else{
			   $name = "Vienam package";
			   $catego = "Vienam package";
			   $title = "Vietnam Package Tours";
		   }
		   $data['listtours'] = $this->model_tour->listtour($id);
		   $config['base_url'] = base_url().$segment."/cruise";
		   $config['total_rows'] = $this->model_tour->count_all_cruise($id);
		   $config['per_page'] = 7;
		   $config['uri_segment'] = 3;
		   $config['cur_tag_open'] = '<span class="active">';
		   $config['cur_tag_close'] = '</span>';
		   $config['next_link'] = "Next";
		   $config['prev_link'] = "Prev";
		   $this->load->library("pagination",$config);  
		   $start = $this->uri->segment(3);
		   $data['listcruise'] = $this->model_tour->list_all_cruise($id,$config['per_page'],$start);
		   $data['listtours'] = $this->model_tour->listtour($id);
		   //$data['listcruise'] = $this->model_tour->listcruise($id);
		   $data['introduc']    = $this->model_index->intro();
		   $data['segment'] = $segment;
		   //$this->debug($data['listcruise']);
		   $data['cateid']  = $id;
		   $data['title']   = $title;
		   $data['name']    = $name; 
		   $data['catego']  = $catego;
		   //$this->debug($data['categories']);
		   $this->load->view("tours/cruises/layout",$data);
	   }
	   public function tour(){
		   $segment = $this->uri->segment(1);
		   $id = array_pop(explode('-',$segment));
		   $data['categories'] = $this->model_tour->get_categories($id);
		   $data['tourname']   = $this->model_index->getcate($id);
		   $data['config']  = $this->config();
		   $data['introduc']    = $this->model_index->intro();
		   if($id == 52){
			   $name = "Hanoi";
			   $catego = "Hanoi Tours";
			   $title = "Hanoi Travel";
		   }elseif($id == 88){
			   $name = "Halong";
			   $catego = "Halong Tours";
			   $title = "Halong Travel";
		   }else{
			   $name = "Vienam package";
			   $catego = "Vienam package";
			   $title = "Vietnam Package Tours";
		   }
		   $config['base_url'] = base_url().$segment."/tour";
		   $config['total_rows'] = $this->model_tour->count_all_cate($id);
		   $config['per_page'] = 7;
		   $config['uri_segment'] = 3;
		   $config['cur_tag_open'] = '<span class="active">';
		   $config['cur_tag_close'] = '</span>';
		   $config['next_link'] = "Next";
		   $config['prev_link'] = "Prev";
		   $this->load->library("pagination",$config);  
		   $start = $this->uri->segment(3);
		   $data['listtours'] = $this->model_tour->list_all_cate($id,$config['per_page'],$start);
		   //$data['listtours'] = $this->model_tour->listtour($id);
		   $data['segment'] = $segment;
		   //$this->debug($data['listtours']);
		   $data['cateid']  = $id;
		   $data['title']   = $title;
		   $data['name']    = $name; 
		   $data['catego']  = $catego;
		   //$this->debug($data['categories']);
		   $this->load->view("tours/tours/layout",$data);
	   }
	   public function overview(){
		   $segment = $this->uri->segment(1);
		   $id = array_pop(explode('-',$segment));
		   $data['categories'] = $this->model_tour->get_categories($id);
		   $data['tourname']   = $this->model_index->getcate($id);
		   $data['config']  = $this->config();
		   if($id == 52){
			   $name = "Hanoi";
			   $catego = "Hanoi Tours";
			   $title = "Hanoi Travel";
		   }elseif($id == 88){
			   $name = "Halong";
			   $catego = "Halong Tours";
			   $title = "Halong Travel";
		   }else{
			   $name = "Vienam package";
			   $catego = "Vienam package";
			   $title = "Vietnam Package Tours";
		   }
		   $data['listtours'] = $this->model_tour->listtour($id);
		   $data['introduc']    = $this->model_index->intro();
		   $data['segment'] = $segment;
		   //$this->debug($data['listtours']);
		   $data['cateid']  = $id;
		   $data['title']   = $title;
		   $data['name']    = $name; 
		   $data['catego']  = $catego;
		   //$this->debug($data['categories']);
		   $this->load->view("tours/overview/layout",$data);
	   }
	   public function hottels(){
		   $segment = $this->uri->segment(1);
		   $id = array_pop(explode('-',$segment));
		   $data['categories'] = $this->model_tour->get_categories($id);
		   $data['tourname']   = $this->model_index->getcate($id);
		   $data['config']  = $this->config();
		   $data['introduc']    = $this->model_index->intro();
		   if($id == 52){
			   $name = "Hanoi";
			   $catego = "Hanoi Tours";
			   $title = "Hanoi Travel";
		   }elseif($id == 88){
			   $name = "Halong";
			   $catego = "Halong Tours";
			   $title = "Halong Travel";
		   }else{
			   $name = "Vienam package";
			   $catego = "Vienam package";
			   $title = "Vietnam Package Tours";
		   }
		   $data['listtours'] = $this->model_tour->listtour($id);
		   $config['base_url'] = base_url().$segment."/hottels";
		   $config['total_rows'] = $this->model_tour->count_all_hottel($id);
		   $config['per_page'] = 7;
		   $config['uri_segment'] = 3;
		   $config['cur_tag_open'] = '<span class="active">';
		   $config['cur_tag_close'] = '</span>';
		   $config['next_link'] = "Next";
		   $config['prev_link'] = "Prev";
		   $this->load->library("pagination",$config);  
		   $start = $this->uri->segment(3);
		   $data['listhottels'] = $this->model_tour->list_all_hottel($id,$config['per_page'],$start);
		   //$data['listhottels'] = $this->model_tour->listhottel($id);
		   $data['segment'] = $segment;
		   //$this->debug($data['listhottels']);
		   $data['cateid']  = $id;
		   $data['title']   = $name." hottels";
		   $data['name']    = $name; 
		   $data['catego']  = $catego;
		   //$this->debug($data['categories']);
		   $this->load->view("tours/hottels/layout",$data);
	   }
	   public function photos(){
		   $segment = $this->uri->segment(1);
		   $id = array_pop(explode('-',$segment));
		   $data['categories'] = $this->model_tour->get_categories($id);
		   $data['tourname']   = $this->model_index->getcate($id);
		   $data['config']  = $this->config();
		   if($id == 52){
			   $name = "Hanoi";
			   $catego = "Hanoi Tours";
			   $title = "Hanoi Travel";
		   }elseif($id == 88){
			   $name = "Halong";
			   $catego = "Halong Tours";
			   $title = "Halong Travel";
		   }else{
			   $name = "Vienam package";
			   $catego = "Vienam package";
			   $title = "Vietnam Package Tours";
		   }
		   $data['photos'] = $this->model_tour->photos($id);
		   $data['introduc']    = $this->model_index->intro();
		   $data['segment'] = $segment;
		   //$this->debug($data['photos']);
		   $data['cateid']  = $id;
		   $data['title']   = $title;
		   $data['name']    = $name; 
		   $data['catego']  = $catego;
		   //$this->debug($data['categories']);
		   $this->load->view("tours/photos/layout",$data);
	   }
	   public function destinations(){
		   $segment = $this->uri->segment(1);
		   $id = array_pop(explode('-',$segment));
		   $data['categories'] = $this->model_tour->get_categories($id);
		   $data['tourname']   = $this->model_index->getcate($id);
		   $data['config']  = $this->config();
		   if($id == 52){
			   $name = "Hanoi";
			   $catego = "Hanoi Tours";
			   $title = "Hanoi Travel";
		   }elseif($id == 88){
			   $name = "Halong";
			   $catego = "Halong Tours";
			   $title = "Halong Travel";
		   }else{
			   $name = "Vienam package";
			   $catego = "Vienam package";
			   $title = "Vietnam Package Tours";
		   }
		   $data['regions'] = $this->model_tour->regions($id);
		   $data['introduc']    = $this->model_index->intro();
		   $data['segment'] = $segment;
		   //$this->debug($data['destinations']);
		   $data['cateid']  = $id;
		   $data['title']   = $title;
		   $data['name']    = $name; 
		   $data['catego']  = $catego;
		   //$this->debug($data['categories']);
		   $this->load->view("tours/destinations/layout",$data);
	   }
	   public function restaur(){
		   $segment = $this->uri->segment(1);
		   $id = array_pop(explode('-',$segment));
		   $data['categories'] = $this->model_tour->get_categories($id);
		   $data['tourname']   = $this->model_index->getcate($id);
		   $data['config']  = $this->config();
		   if($id == 52){
			   $name = "Hanoi";
			   $catego = "Hanoi Tours";
			   $title = "Hanoi Travel";
		   }elseif($id == 88){
			   $name = "Halong";
			   $catego = "Halong Tours";
			   $title = "Halong Travel";
		   }else{
			   $name = "Vienam package";
			   $catego = "Vienam package";
			   $title = "Vietnam Package Tours";
		   }
		   $data['restaurants'] = $this->model_tour->restaurants($id);
		   $data['introduc']    = $this->model_index->intro();
		   $data['segment'] = $segment;
		   //$this->debug($data['restaurants']);
		   $data['cateid']  = $id;
		   $data['title']   = $title;
		   $data['name']    = $name; 
		   $data['catego']  = $catego;
		   //$this->debug($data['categories']);
		   $this->load->view("tours/restaurants/layout",$data);
	   }
	   public function view(){
		   $extends = $this->uri->segment(1);
		   $segment = $this->uri->segment(2);
		   $id = array_pop(explode('-',$segment));
		   $id1 = array_pop(explode('-',$extends));
		   $data['result'] = $this->model_tour->gettour($id);
		   if($data['result'] == NULL){
			   redirect(base_url());
		   }
		   if($id1 == 52){
			   $name = "Hanoi";
			   $catego = "Hanoi Tours";
			   $title = "Hanoi Travel";
		   }elseif($id1 == 88){
			   $name = "Halong";
			   $catego = "Halong Tours";
			   $title = "Halong Travel";
		   }else{
			   $name = "Vienam package";
			   $catego = "Vienam package";
			   $title = "Vietnam Package Tours";
		   }
		   $data['listtours'] = $this->model_tour->listtour(88);
		   $data['introduc']    = $this->model_index->intro();
		   $data['extends'] = $extends;
		   $data['catename'] = $title;
		   $cate_id = $data['result']['cate_id'];
		   $data['related'] = $this->model_tour->related($cate_id,$id,"tour_id","tbl_tours");
		   //$this->debug($data['related']);
		   $data['relatedtop'] = $this->model_tour->related_show($cate_id,"tour_show","tbl_tours");
		   $data['title'] = $data['result']['tour_name'];
		   $this->load->view("tours/detail/layout",$data);
	   }
	   public function cruise_detail(){
		   $extends = $this->uri->segment(1);
		   $segment = $this->uri->segment(3);
		   $id = array_pop(explode('-',$segment));
		   $id1 = array_pop(explode('-',$extends));
		   $data['result'] = $this->model_tour->getcruise($id);
		   if($data['result'] == NULL){
			   redirect(base_url());
		   }
		   if($id1 == 52){
			   $name = "Hanoi";
			   $catego = "Hanoi Tours";
			   $title = "Hanoi Travel";
		   }elseif($id1 == 88){
			   $name = "Halong";
			   $catego = "Halong Tours";
			   $title = "Halong Travel";
		   }else{
			   $name = "Vienam package";
			   $catego = "Vienam package";
			   $title = "Vietnam Package Tours";
		   }
		   //$this->debug($data['result']);
		   //$data['listtours'] = $this->model_tour->listtour(88);
		   $data['extends'] = $extends;
		   $data['catename'] = $title;
		   $cate_id = $data['result']['cate_id'];
		   $data['introduc']    = $this->model_index->intro();
		   $data['related'] = $this->model_tour->related($cate_id,$id,"cruise_id","tbl_cruises");
		   $data['relatedtop'] = $this->model_tour->related_show($cate_id,"cruise_show","tbl_cruises");
		   $data['title'] = $data['result']['cruise_name'];
		   $this->load->view("tours/detail_cruise/layout",$data);
	   }
	   public function hottel_detail(){
		   $extends = $this->uri->segment(1);
		   $segment = $this->uri->segment(3);
		   $id = array_pop(explode('-',$segment));
		   $id1 = array_pop(explode('-',$extends));
		   $data['result'] = $this->model_tour->gethottel($id);
		   if($data['result'] == NULL){
			   redirect(base_url());
		   }
		   if($id1 == 52){
			   $name = "Hanoi";
			   $catego = "Hanoi Tours";
			   $title = "Hanoi Travel";
		   }elseif($id1 == 88){
			   $name = "Halong";
			   $catego = "Halong Tours";
			   $title = "Halong Travel";
		   }else{
			   $name = "Vienam package";
			   $catego = "Vienam package";
			   $title = "Vietnam Package Tours";
		   }
		   //$this->debug($data['result']);
		   //$data['listtours'] = $this->model_tour->listtour(88);
		   $data['extends'] = $extends;
		   $data['catename'] = $title;
		   $data['introduc']    = $this->model_index->intro();
		   $cate_id = $data['result']['cate_id'];
		   $data['related'] = $this->model_tour->related($cate_id,$id,"hottel_id","tbl_hottels");
		   $data['relatedtop'] = $this->model_tour->related_show($cate_id,"hottel_show","tbl_hottels");
		   $data['title'] = $data['result']['hottel_name'];
		   $this->load->view("tours/detail_hottel/layout",$data);
	   }
	   public function category(){
		   $seg1 = $this->uri->segment(1);
		   $seg2 = $this->uri->segment(3);
		   $id = $this->uri->segment(2);
		   $val = array_pop(explode("-",$seg1));
		   if($val == 52){
			   $name = "Hanoi";
			   $catego = "Hanoi Tours";
			   $title = "Hanoi Travel";
		   }elseif($val == 88){
			   $name = "Halong";
			   $catego = "Halong Tours";
			   $title = "Halong Travel";
		   }else{
			   $name = "Vienam package";
			   $catego = "Vienam package";
			   $title = "Vietnam Package Tours";
		   }
		   $data['categories'] = $this->model_tour->get_categories($val);
		   $config['base_url'] = base_url().$seg1."/".$id."/".$seg2;
		   $config['total_rows'] = $this->model_tour->count_all($id);
		   $config['per_page'] = 7;
		   $config['uri_segment'] = 4;
		   $config['cur_tag_open'] = '<span class="active">';
		   $config['cur_tag_close'] = '</span>';
		   $config['next_link'] = "Next";
		   $config['prev_link'] = "Prev";
		   $this->load->library("pagination",$config);  
		   $start = $this->uri->segment(4);
		   $data['results'] = $this->model_tour->list_all($id,$config['per_page'],$start);
		   $ok = $this->model_tour->getcago($id);
		   $data['introduc']    = $this->model_index->intro();
		   if($ok == NULL){
			   redirect(base_url());
		   }
		   //$this->debug($data['results']);
		   $data['title'] = $ok['cago_name'];
		   $data['name']    = $title; 
		   $data['catego']  = $catego;
		   $data['segment'] = $seg1;
		   $this->load->view("tours/category/layout",$data);
	   }
   }